using System.Collections;
using UnityEngine;

public class SelfDestructBird : Bird
{
    [Header("自爆半径")]
    [SerializeField] float radius = 2.5f;
    [Header("伤害值")]
    [SerializeField] float ad = 50;

    private GameObject prefabBoom;

    public SelfDestructBird()
    {
        base.BirdType = BirdType.SelfDestruct;
    }

    protected override void OtherLoad()
    {
        base.OtherLoad();
        this.prefabBoom = Resources.Load<GameObject>("Prefabs/Items/Boom");
    }

    protected override void BoomSkill()
    {
        base.BoomSkill();
        var colliders = Physics2D.OverlapCircleAll(transform.position, this.radius);

        foreach (var collider in colliders)
        {
            var destruction = collider.GetComponent<Destruction>();
            if (destruction)
            {
                destruction.Damage(this.ad);
            }
        }

        Destroy(gameObject);
        Instantiate(this.prefabBoom, transform.position, Quaternion.identity).GetComponent<Boom>().Show(true);
        GameManager.Instance.FlyFinished(1.0f);
    }
}